#include "include/Asset.h"

// 强制UTF-8

std::wostream& operator<<(std::wostream &out, Asset asset) {
	if (asset.isImage)
		THROW("Asset isn't a wide char");
	out << *asset.asset.tchar;
	return out;
}

std::ostream &operator<<(std::ostream &out, Asset asset) {
	if (asset.isImage)
		THROW("Asset isn't a wide char");
	out << char(*asset.asset.tchar);
	return out;
}

Asset::Asset(wchar_t tchar) {
	this->asset.tchar = new wchar_t(tchar);
	isImage = false;
}

Asset::Asset(Image &&img) {
	this->asset.image = new Image(img);
	isImage = true;
}

wchar_t Asset::operator=(wchar_t tchar) {
	*this->asset.tchar = tchar;
	if (isImage)
		isImage = false;
	return tchar;
}

Image Asset::operator=(Image img) {
	*this->asset.image = img;
	this->isImage = true;
	return img;
}
